<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<base href="http://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/">
<script type="text/javascript" src="jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="layer/layer.js"></script>
<head>
<script type="text/javascript">
    $(function () {
        $("#btn1").click(function () {
            $.ajax({
                url:"sendBtn1.html",
                type:"post",
                data:{
                    "array":[1,2,3]
                },
                success:function(data){
                    console.log(data);
                },
                error:function(data){
                    console.log(data);
                }
            })
        })

        var array2 = [4,5,6];
        var requestData = JSON.stringify(array2);
        $("#btn2").click(function(){
            $.ajax({
                url:"sendbtn2.html",
                data:requestData,
                type:"post",
                dataType:"text",
                contentType:"application/json;charset=UTF-8",
                success:function (response) {
                    console.log(response);
                },
                error:function (response) {
                    console.log(response);
                }

            })
        })

        var student = {
            "id":1,
            "name":"stone",
            "mom":{
                "name":"xia",
                "age":40
            },
            "courseList":[
                {"courseId":1,"courseName":"Chinese"},
                {"courseId":2,"courseName":"math"}
            ],
            "map":{
                "k1":"v1",
                "k2":"v2"
            }
        }
        var requestStu = JSON.stringify(student);
        $.ajax({
            url:"sendbtn3.json",
            type:"post",
            data:requestStu,
            contentType: "application/json;charset=UTF-8",
            dataType:"text",
            success:function (responseData) {
                console.log(responseData);
            },
            error:function (responseData) {
                console.log(responseData);
            }
        })

        $("#btn4").click(function () {
            layer.msg("layer success");
        })

    })


</script>

</head>
<body>
<a href="hello.html">hello</a>
<br>
<button id="btn1" >button1</button>
<br>
<button id="btn2" >button2</button>
<br>
<button id="btn3" >button3</button>
<br>
<button id="btn4" >button4</button>
</body>
</html>
